<template>
	<view class="box">
		<u-navbar height="50" :is-back="true" title="商家中心" :border-bottom="false" title-color="#333" title-size="36">
		</u-navbar>
		<!-- 商家信息 -->
		<view class="business-info"  v-if="storeInfo" @click="goPage('/other/BusinessInfo/BusinessInfo')">
			<view class="left">
				<image :src="storeInfo.logo" mode="widthFix" style="width: 150rpx; height: 150rpx;"></image>
			</view>
			<view class="right">
				<view class="name">
					<span>{{storeInfo.name}}</span>
				</view>

				<view class="address">
					<u-icon :name="'/static/icon/dwei.png'" size="28"></u-icon> <span class="ct">{{storeInfo.zone}}</span>
				</view>
			</view>
		</view>
		<!-- 商品订单 -->
		<view class="goodsOrder">
			<view class="top">
				<view class="title">
					商品订单
				</view>
				<view class="more" @click="goOrderDetail(-1)">
					更多<span class="icon"></span>
				</view>
			</view>
			<view class="list">
				<view class="item" v-for="(item,index) in list" :key="index" @click="goOrderDetail(index)">
					<view class="num">
						{{item.num}}
					</view>
					<view class="ct">
						{{item.ct}}
					</view>
				</view>
			</view>
		</view>
		<!-- 操作 -->
		<!-- <view class="act">
			<view class="item" v-for="item in activity" :key="item.id" @click="goPage(item.path)">
				<view class="pic">
					<image :src="item.icon" mode="widthFix" style="width: 90rpx; height: 90rpx;"></image>
				</view>
				<view class="title">
					{{item.title}}
				</view>
			</view>
		</view> -->
		<!-- 商品管理 -->
		<view class="goodsOrder">
			<view class="top">
				<view class="title">
					商品管理
				</view>
				<view class="more" @click="goPage('/other/goodsManage/goodsManage?id=-1')">
					更多<span class="icon"></span>
				</view>
			</view>
			<view class="list">
				<view class="item" v-for="(item,index) in manageList" :key="index" @click="goPage(item.path)">
					<view class="num">
						{{item.num}}
					</view>
					<view class="ct">
						{{item.ct}}
					</view>
				</view>
			</view>
		</view>
		<!-- 店铺收益统计 -->
		<view class="stats">
			<view class="title">
				店铺收益统计
			</view>
			<view class="itemBox">
				<view class="item" v-for="(item,index) in statsList" :key="index">
					<view class="num">
						{{item.num}} <span class="unit" v-if="item.type=='money'">元</span><span class="unit" v-if="item.type=='num'">单</span><span class="unit" v-if="item.type=='people'">人</span>
					</view>
					<view class="ct">
						{{item.ct}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getStoreInfo
	} from '../../api/store.js'
	import {GetOrderStat,GetBuIncome,GetGoodsStat} from '@/api/user.js'
	export default {
		data() {
			return {
				list: [{
						num: 100,
						ct: '待付款'
					},
					{
						num: 168,
						ct: '待发货'
					},
					{
						num: 168,
						ct: '待收货'
					}, {
						num: 10,
						ct: '已完成'
					}
				],
				activity: [
					// {
					// 	id: 1,
					// 	icon: '/static/McInfo/yxhd.png',
					// 	title: '营销活动',
					// 	path:'/other/marketing/marketing'
					// },
					{
						id: 2,
						icon: '/static/McInfo/ddhx.png',
						title: '订单核销',
						path:'/other/Verification/Verification'
					}, {
						id: 3,
						icon: '/static/McInfo/dpxxgl.png',
						title: '商家信息',
						path:'/other/BusinessInfo/BusinessInfo'
					}
				],
				manageList: [{
						num: 100,
						ct: '销售中',
						path:'/other/goodsManage/goodsManage?id=0'
					},
					{
						num: 66,
						ct: '已下架',
						path:'/other/goodsManage/goodsManage?id=1'
					},
					{
						num: 12,
						ct: '已售罄',
						path:'/other/goodsManage/goodsManage?id=2'
					}
				],
				statsList: [{
						num: 671.06,
						ct: '今日收益',
						type: "money"
					},
					{
						num: 66,
						ct: '待入账',
						type: "money"
					},
					{
						num: 1280,
						ct: '累计总收益',
						type: "money"
					}
				],
				storeInfo:""
			};
		},
		onLoad() {
			this.initData()
			
		},
		methods:{
			initData(){
				GetOrderStat().then(res=>{
					console.log("店铺订单统计",res)
					this.list[0].num = res.data.notpay
					this.list[1].num = res.data.pay
					this.list[2].num = res.data.transit
					this.list[3].num = res.data.finish
				})
				GetBuIncome().then(res=>{
					console.log("店铺收益",res)
					this.statsList[0].num = res.data.today
					this.statsList[1].num = res.data.nothave
					this.statsList[2].num = res.data.total
				})
				GetGoodsStat().then(res=>{
					console.log("店铺商品统计",res)
					this.manageList[0].num = res.data.sale
					this.manageList[1].num = res.data.notsale
					this.manageList[2].num = res.data.saleout
				})
				let id= uni.getStorageSync('chainId')
				getStoreInfo(id).then(res=>{
					console.log("商家信息",res);
					this.storeInfo = res.data
				})
			},
			goOrderDetail(index){
				uni.navigateTo({
					url:'/page/McCenterOrder/McCenterOrder?index='+index
				})
			},
			goPage(url){
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		min-height: 100vh;
		background-color: #f5f5f5;
		padding-bottom: 20rpx;
	}

	// 商家信息
	.business-info {
		width: 710rpx;
		box-sizing: border-box;
		padding: 30rpx 20rpx;
		margin-top: 20rpx;
		margin-left: 20rpx;
		background-color: #fff;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #333333;
		display: flex;
		justify-content: space-between;
		align-items: center;

		border-radius: 10rpx;

		.left {
			width: 150rpx;
			height: 150rpx;
			border-radius: 20rpx;
			overflow: hidden;

		}

		.right {
			width: 490rpx;
			height: 150rpx;

			.name {
				height: 50rpx;
				line-height: 50rpx;
				font-size: 32rpx;
				display: flex;
				justify-content: space-between;
			}



			.hours {
				display: flex;
				align-items: center;
				height: 50rpx;
				font-size: 24rpx;
			}

			.hours .ing {
				width: 96rpx;
				height: 40rpx;
				background: #6BC665;
				border-radius: 20rpx;
				display: block;
				text-align: center;
				line-height: 40rpx;
				color: #fff;
				margin: 0 20rpx;
				font-size: 22rpx;
			}

			.address {
				display: flex;
				height: 50rpx;
				align-items: center;
			}

			.address .ct {
				display: block;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
				font-size: 24rpx;
				color: #999999;
			}



		}

	}

	// 订单信息
	.goodsOrder {
		width: 710rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		margin: 20rpx auto;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #333333;
		box-sizing: border-box;
		padding: 20rpx;

		.top {
			font-size: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 10rpx 0;

			.more {
				color: #ABA9A2;
				font-size: 24rpx;
			}

			.more .icon {
				display: inline-block;
				width: 20rpx;
				height: 20rpx;
				background-image: url('/static/arrow.png');
				background-size: cover;
				background-repeat: no-repeat;
			}
		}

		.list {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 10rpx;
			box-sizing: border-box;

			.item {
				text-align: center;
				width: 160rpx;
				padding: 10rpx 0;

			}

			.item .num {
				padding: 5rpx 0;
			}

			.item .ct {
				padding: 5rpx 0;
			}
		}
	}

	// 操作
	.act {
		width: 710rpx;
		height: 200rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		margin: 20rpx auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 40rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #333333;

		.item {
			display: flex;
			flex-direction: column;
			align-items: center;
		}
	}
	// 店铺收益统计
	.stats{
		width: 710rpx;
		height: 330rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #333333;
		box-sizing: border-box;
		padding: 20rpx 40rpx;
		margin: 20rpx auto;
		.title{
			font-size: 30rpx;
			color: #333333FF;
		}
		
		.itemBox{
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;
			margin:10rpx;
			font-size: 26rpx;
			.item{
				width: 204rpx;
				text-align: center;
			}
			.item .num .unit{
				font-size: 26rpx;
			}
			.item .num{
				font-size: 32rpx;
				margin: 15rpx 0;
			}
		}

		
	}
</style>